package com.zemo.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import com.zemo.entity.Product;
import com.zemo.service.ProductService;

/**
 * @ClassName: ProductController
 * @author: SuperZemo
 * @date: Mar 31, 2014 2:09:24 AM
 * @email:chenzeming@lanbaoo.com
 * @Description: 商品相关传值，跳转
 */
@Controller
@RequestMapping("/product")
public class ProductController {

	@Autowired
	private ProductService productService;
	
	@RequestMapping("/list")
	public ModelAndView listProduct(){
		List<Product> products = productService.listAllProducts();
		
		return new ModelAndView("products","products",products);
	} 
	
	@RequestMapping("/get")
	public ModelAndView getProduct(@RequestParam(value="id",required = true)int id){
		
		return new ModelAndView("detail","product",productService.getProduct(id));
	} 
}
